#include <bits/stdc++.h>

using namespace std;

const int maxn=3005;
const int maxm=9005;

int g[maxn],v[maxm],nxt[maxm],cap[maxm],en=2;
int from[maxn],que[maxn];
int haseed=233,ha[4][maxn];
int S,T,n;
int points[maxn];

inline void addEdge(const int &x,const int &y,const int &w){
    v[en]=y;cap[en]=w;nxt[en]=g[x];g[x]=en++;
    v[en]=x;cap[en]=w;nxt[en]=g[y];g[y]=en++;
}
inline bool bfs(){
    //printf("bfs,S=%d,T=%d\n",S,T);
    int *f,*r;
    f=r=que;
    memset(from,-1,sizeof(from));

    for(from[*(r++)=S]=0;f<r;f++){
        for(int j=g[*f];j;j=nxt[j]){
            if(!cap[j]) continue;
            if(from[v[j]]+1) continue;
            from[*(r++)=v[j]]=j;
        }
    }
    if(from[T]==-1) return false;

    for(int j=T;from[j];j=v[from[j]^1]){
        //printf("j=%d,from[j]=(%d,%d)\n",j,v[from[j]^1],v[from[j]]);
        cap[from[j]]--;
        cap[from[j]^1]++;
    }
    //for(int i=2;i<en;i++) printf("(%d,%d,%d,%d)\n",v[i^1],v[i],cap[i],cap[i^1]);
    //getchar();
    return true;
}
inline void restore(){
    for(int i=2;i<en;i++) cap[i]=1;
}
inline void solve(int l,int r){
    //printf("solve(%d,%d)\n",l,r);
    int maxflow=0;
    if(l>=r) return;
    restore();
    S=points[l];T=points[r];
    while(bfs()) maxflow++;
    //if(maxflow==2) printf("maxflow=2,l=%d,r=%d\n",points[l],points[r]);
    haseed*=521;
    for(int i=1;i<=n;i++) if(~from[i]) ha[maxflow][i]+=haseed;
    int *pol=que+l,*por=que+r;
    for(int i=l;i<=r;i++) if(~from[points[i]]) *(pol++)=points[i];else *(por--)=points[i];
    memcpy(points+l,que+l,sizeof(int)*(r-l+1));
    solve(l,por-que);solve(pol-que,r);
}

int main(){
    int m,x,y,sum;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%d%d",&x,&y);
        addEdge(x,y,1);
    }
    for(int i=1;i<=n;i++) points[i]=i;
    solve(1,n);
    sum=0;
    for(int i=1;i<=n;i++) for(int j=i+1;j<=n;j++) for(int maxflow=0;maxflow<4;maxflow++) if(ha[maxflow][i]!=ha[maxflow][j]) {/*printf("(%d,%d)=%d\n",i,j,maxflow);*/sum+=maxflow;break;}
    //for(int i=1;i<=n;i++) printf("%d ",ha[2][i]);putchar('\n');
    printf("%d\n",sum);
    return 0;
}


